<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core" lang="pt-br">

<f:view>
		<h:panelGroup id="group_telefone" rendered="#{telefoneManager.renderPanelCadastro}">
			<p:message for="tipo_telefone" id="message_tipoTelefone"/>
			<p:message for="ddd" id="message_ddd"/>
			<p:message for="numero" id="message_numero"/>
			
			<h:panelGrid columns="2" id="grid_telefone">
				<h:outputLabel for="tipo_telefone" value="Tipo" />
				<h:outputLabel for="ddd" value="Telefone" />
				
				<h:selectOneMenu value="#{telefoneManager.telefone.tipoTelefone}" label="Tipo de Telefone" id="tipo_telefone">
					<f:selectItems value="#{utilManager.listTipoTelefone}"/>
				</h:selectOneMenu>
				
				<h:panelGroup>
					<p:inputMask value="#{telefoneManager.telefone.ddd}" size="5" maxlength="2" label="DDD" id="ddd" mask="99"/>
					<p:inputMask value="#{telefoneManager.telefone.numero}" maxlength="8" label="Número" id="numero" mask="9999-9999" converter="maskConverter"/>
				</h:panelGroup>
		
				<p:commandButton value="Adicionar" action="#{telefoneManager.addTelefone}" process="grid_telefone" update="group_telefone,panel_telefone"/>
			</h:panelGrid>
		</h:panelGroup>
		
		<hr class="border-top mv5"/>
		
		
		<h:panelGroup id="panel_telefone">
			<p:dataTable id="table_telefone" var="telefone" emptyMessage="Nenhum telefone foi adicionado." value="#{telefoneManager.listTelefone}" rows="3" paginator="true">
				<p:column headerText="Tipo de Telefone">
					<h:outputText value="#{telefone.tipoTelefone.descricao}" />
				</p:column>
				<p:column headerText="Número">
					(<h:outputText value="#{telefone.ddd}" />)
					<h:outputText value="#{telefone.numero}" />
				</p:column>
				<p:column headerText="" rendered="#{telefoneManager.renderPanelCadastro}">
					<p:commandButton value="Remover" action="#{telefoneManager.removeTelefone}" update=":form:tab:panel_telefone" disabled="#{pacienteManager.isTelaAtendimento}">
						<f:setPropertyActionListener target="#{telefoneManager.telefone}" value="#{telefone}"/>
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</h:panelGroup>
</f:view>
</html>